<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<%@ include file="/common-css.jsp" %>
<%@ include file="/common-js.jsp" %>
<body>
<form class="layui-form layui-form-pane1"> <!-- 提示：如果你不想用form，你可以换成div等任何一个普通元素 -->
  <div class="layui-form-item">
    <label class="layui-form-label">角色名称</label>
    <div class="layui-input-block">
      <input type="text" name="name" value="${entity.name}" placeholder="请输入角色名称"
      	lay-verify="required" autocomplete="off" class="layui-input">
    </div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">排序</label>
    <div class="layui-input-block">
      <input type="text" name="seq" value="${entity.seq}" placeholder="请输入排序" 
      		lay-verify="required|number" autocomplete="off" class="layui-input">
    </div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">状态</label>
    <div class="layui-input-block">
      	<input type="radio" name="status" value="0" title="正常" <c:if test="${entity.status==0 }">checked</c:if>>
		<input type="radio" name="status" value="1" title="停用" <c:if test="${entity.status==1 }">checked</c:if>>
    </div>
  </div>
  
  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">备注</label>
    <div class="layui-input-block">
      <textarea name="description" placeholder="请输入内容" class="layui-textarea">${entity.description }</textarea>
    </div>
  </div>
  
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="*">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
  <!-- 更多表单结构排版请移步文档左侧【页面元素-表单】一项阅览 -->
</form>
</body>
<script type="text/javascript">
layui.use(['form','jquery','layer'],function(){
	var form = layui.form;
	var $ = layui.jquery;
	var layer = parent.layer === undefined?layui.layer:parent.layer;
	
	//监听提交事件
	form.on('submit(*)',function(data){
		//console.info(data.field); //当前容器的全部表单字段，名值对形式：{name: value}
		var pli = progressLoad();//加载提交等待提示窗口
		$.post("${pageContext.request.contextPath}/sys/sysRole/add", data.field, function(ret){
			progressClose(pli);//关闭提交等待提示窗口
			ret = $.parseJSON(ret);
			//console.info("响应结果："+ret);
			if(ret.success){
				top.layer.msg(ret.msg);
	 			layer.closeAll("iframe");
		 		//刷新父页面
		 		parent.location.reload();
			}else{
				layer.msg(ret.msg);
			}
		});
		
		return false;//阻止表单跳转。如果需要表单跳转，去掉这段即可。
	});//form.on('submit(form1)',function(data){ End

	
	//监听select选项
	form.on('select(status)',function(data){
// 		console.log(data.elem); //得到select原始DOM对象
//   		console.info(data.value); //得到被选中的值
//   		console.log(data.othis); //得到美化后的DOM对象
	});

});
</script>
</html>